<?php

use Thrift\Protocol\TFramedTransport;
use Thrift\Protocol\TTransport;
use Thrift\Protocol\TBinaryProtocol;
use Thrift\Transport\TSocket;
use Thrift\Transport\THttpClient;
use Thrift\Transport\TBufferedTransport;
use Thrift\Exception\TException;

$transport = new TSocket('localhost', 7911);
$transport->open();

$protocol = new TBinaryProtocol($transport);

$client= new ArbolClient($protocol, $protocol);

if ($_FILES["file"]["error"] > 0){
  	echo "Error: " . $_FILES["file"]["error"] . "<br>";
} else {
	echo "Upload: " . $_FILES["file"]["name"] . "<br>";
	echo "Type: " . $_FILES["file"]["type"] . "<br>";
	echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>";
	echo "Stored in: " . $_FILES["file"]["tmp_name"] . "<br>";

	$handle = fopen($_FILES["file"]["tmp_name"], "r");
	if ($handle) {
		while (($line = fgets($handle)) !== false) {
			echo $line . "<br>";
			$result = $client->add('param1');
			Print 'result = ' . $result;
		}
	} else {
		echo "Error al abrir el archivo";
	}
}
?> 